package com.icarsaas.saas.component.base;

import com.icarsaas.saas.common.page.Page;
import com.icarsaas.saas.tenant.test.repository.CommitteeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class BaseService {
	
	@Autowired private CommitteeRepository committeeRepository;
	
	public Page<Map<String, Object>> listUserData(Page<Map<String, Object>> page, Map<String, Object> params) {
		StringBuffer sql = new StringBuffer("select t.id,t.username,t.tenant,t.nickname,t.phone,t.status,t.dept_id,t.create_date from sys_user t where 1=1 ");
		if (params != null && params.size() > 0) {
			for (String key : params.keySet()) {
				Object value = params.get(key);
				if (value != null) sql = sql.append(" and t." + key + " like '%" + value + "%'");
			}
		}
		Page<Map<String, Object>> pageResult = committeeRepository.findBySql(page, sql.toString(), Map.class);
		return pageResult;
	}
	
	
}
